package com.csdj.t309springboot.controller;

import com.csdj.t309springboot.common.WebResult;
import com.csdj.t309springboot.entity.User;
import com.csdj.t309springboot.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

@Controller
public class TestController {

    @Resource
    private UserService userService;

    @GetMapping("/index")
    public String test(Model model){
        List<String> list = Arrays.asList("kitty","wudy","rose","tony");
        User user = new User();
        user.setUsername("cloudddd");
        model.addAttribute("user",user);
        model.addAttribute("list",list);
        return "index";
    }

    @ResponseBody
    @GetMapping("/test")
    public WebResult test(){
        return   new WebResult(1)
                .putData("data","msg")
                .putData("age",22)
                .putData("address","cs")
                .putData("name","cloud");
    }
}
